package com.nlelpct.model.vo;

/**
 * Copyright @2018 nlelpct.
 * @author: 黄磊
 * date:  2019/3/26  16:00
 * use to：全局错误代码以及提示转发处理
 * modify：
 */
public class CodeMsg {

    private int code;
    private String msg;

    //全局通用异常
    public static CodeMsg SERVER_ERROR = new CodeMsg(520520, "启奏皇上，服务端异常！");
    public static CodeMsg SERVER_ERRORS = new CodeMsg(520520, "启奏皇上，服务端异常！%s");
    //common-service 模块
    public static final CodeMsg AUTHORISE_FAIL = new CodeMsg(500201, "密码错误，JWT授权失败！");
    public static final CodeMsg NO_SUCH_SYSTEM = new CodeMsg(500202, "没有该系统错误！");
    public static final CodeMsg SYSTEM_PASS_ERROR = new CodeMsg(500202, "系统校验码错误！");
    public static final CodeMsg TOKEN_ERROR_EXPIRED = new CodeMsg(500203, "TOKEN过期，请重新登录！");
    public static final CodeMsg TOKEN_ERROR_INVALID = new CodeMsg(500203, "TOKEN不合法，请重新登录！");
    public static final CodeMsg EXPIRED_IN_REDIS = new CodeMsg(500203, "SESSION过期，请重新登录！");
    public static final CodeMsg CAN_NOT_BE_EMPTY = new CodeMsg(500103, "参数错误：%s");
    //公用模块
    //格式化字符串
    public static CodeMsg SERVER_BIND_ERROR = new CodeMsg(500101, "服务端绑定异常:%s,%d");
    public static CodeMsg MSG_PASSWORD_IS_EMPTY = new CodeMsg(500201, "密码不能为空！");
    private CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public CodeMsg fillArgs(Object ... args){
        int code=this.code;
        String message=String.format(msg,args);
        return new CodeMsg(code,message);
    }
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
}
